package com.mind.customer.utils;

import com.alibaba.fastjson2.JSONArray;
import com.mind.customer.mapper.AjMapTableMapper;
import com.mind.system.domain.AjMapTable;
import org.springframework.stereotype.Component;

import jakarta.annotation.Resource;
import java.util.Arrays;
import java.util.List;

@Component
public class OrgUtils {
    @Resource
    private AjMapTableMapper mapTableMapper;
    public List<String> getInvoiceLines(String orgCode){
        return Arrays.asList("p","c","b","s","r","j","u","t","h","bs","pc","es","ec","ck","hg","e","f","jd","dz","ck","qc","hc","fj","ky","cz","de","fi","bc");
    }

    public String getOrgCode(String orgId){
        AjMapTable mapTable = mapTableMapper.selectMapTableByName("申请公司映射表");
        if(mapTable == null) {
            return orgId;
        }
        JSONArray array = JSONArray.parseArray(mapTable.getTableObject());
        for(int i=0;i<array.size();i++){
            if(array.getJSONObject(i).getString("申请公司code").equals(orgId))
                return array.getJSONObject(i).getString("法人公司code");
        }
        return orgId;
    }
}
